import { userLogin } from '../api/user'
const state = {
  userid:'',
  username:'',//账号
  name:'',//店铺名
  info:'',//店铺简介
  img:'',//店铺头像
  notice:''//公告
}
const mutations = {
  SET_USER_INFO(state, payload) {
    state.userid = payload._id
    state.username = payload.username
    state.name = payload.name
    state.info = payload.info
    state.img = payload.img
    state.notice = payload.notice
  },
}
const actions = {
  async postUserLogin(store, data) {
    let res = await userLogin(data)
    console.log(res.data.data[0]);
    if(res.data.code==200){
      store.commit('SET_USER_INFO',res.data.data[0])
      return res.data
    }else{
      return res.data
    }
    
  }
}
export default {
  state, mutations, actions
}